//
//  ItemForExploreCollectionView.m
//  echo
//
//  Created by dllo on 16/1/27.
//  Copyright © 2016年 Danny. All rights reserved.
//

#define WIDTH [UIScreen mainScreen].bounds.size.width / 414
#define HEIGHT [UIScreen mainScreen].bounds.size.height / 736

#import "ItemForExploreCollectionView.h"
#import <SDWebImage/UIButton+WebCache.h>
#import "ModelForExploreCollectionView.h"

@interface ItemForExploreCollectionView ()
@property (nonatomic, retain)UIView *viewForBack;
@end

@implementation ItemForExploreCollectionView

- (void)dealloc{
    [_button release];
    [_label release];
    [_viewForBack release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.viewForBack = [[UIView alloc]init];
        [self.contentView addSubview:self.viewForBack];
        [self.viewForBack release];
        
        self.button = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.viewForBack addSubview:self.button];
        
        self.label = [[UILabel alloc]init];
        [self.viewForBack addSubview:self.label];
        [self.label release];
    }
    
    return self;
}

- (void)layoutSubviews{
    
    [super layoutSubviews];
    
    self.viewForBack.frame = self.contentView.frame;
    
    self.button.frame = CGRectMake(0, 0, ([UIScreen mainScreen].bounds.size.width - 10 * WIDTH - 15 * WIDTH * 5)/5, ([UIScreen mainScreen].bounds.size.width - 10 * WIDTH - 15 * WIDTH * 5)/5);
    self.button.layer.cornerRadius = ([UIScreen mainScreen].bounds.size.width - 10 * WIDTH - 15 * WIDTH * 5)/5/2  ;
    self.button.layer.masksToBounds = YES;
    
    self.label.frame = CGRectMake(0, ([UIScreen mainScreen].bounds.size.width - 10 * WIDTH - 15 * WIDTH * 5)/5, ([UIScreen mainScreen].bounds.size.width - 10 * WIDTH - 15 * WIDTH * 5)/5, self.contentView.frame.size.height - ([UIScreen mainScreen].bounds.size.width - 10 * WIDTH - 15 * WIDTH * 5)/5);
    self.label.font = [UIFont fontWithName:@"Arial" size:14.0];
    self.label.textAlignment = NSTextAlignmentCenter;
    
}

- (void)passModel:(ModelForExploreCollectionView *)model{

    [self.button sd_setBackgroundImageWithURL:[NSURL URLWithString:@"http://7xavig.com2.z0.glb.qiniucdn.com/new_channel_category/pd_qingxu2x.png"] forState:UIControlStateNormal];
    
    self.label.text = @"音乐类型";
}

@end
